cmake_minimum_required(VERSION 3.8)
project(wearhouse_navigation)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(rosidl_default_runtime REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(action_msgs REQUIRED)

# Find JsonCpp
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)


rosidl_generate_interfaces(${PROJECT_NAME}
 "action/NavigateToPose.action"
 DEPENDENCIES
  geometry_msgs
  action_msgs
  std_msgs
  tf2
  tf2_geometry_msgs
)

# 包含目录
include_directories(
  include
  ${JSONCPP_INCLUDE_DIRS}
)

# 创建可执行文件
add_executable(wearhouse_navigator src/wearhouse_navigator.cpp)


# ament target dependencies
ament_target_dependencies(wearhouse_navigator
  rclcpp
  geometry_msgs
  sensor_msgs
  std_msgs
  tf2
  tf2_geometry_msgs
  action_msgs
  rosidl_default_runtime
)

# 链接生成的接口库
# 这一步至关重要，确保你的可执行文件能使用生成的 Action 消息
rosidl_target_interfaces(wearhouse_navigator 
${PROJECT_NAME} "rosidl_typesupport_cpp")

# 链接库
target_link_libraries(wearhouse_navigator
  ${JSONCPP_LIBRARIES}
)



#install targets
install(TARGETS
  wearhouse_navigator
  EXPORT export_${PROJECT_NAME}
  INCLUDES DESTINATION include
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)


install(DIRECTORY include/
  DESTINATION include/
)

install(DIRECTORY 
  config
  launch
  DESTINATION share/${PROJECT_NAME}
)

# 安装 action 文件本身
# 虽然 rosidl_generate_interfaces 会处理它们，但通常也建议安装到 share 目录
install(DIRECTORY
  action/
  DESTINATION share/${PROJECT_NAME}/action
)



if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()




ament_export_include_directories(include)
ament_export_dependencies(
  rclcpp
  geometry_msgs
  sensor_msgs
  std_msgs
  tf2
  tf2_geometry_msgs
  rosidl_default_runtime
)



ament_package()
